<template>
  <div>
    <h1>个人信息</h1>
    <h3>{{ $route.params.id }}</h3>
    <h3>{{name}}</h3>
  </div>
</template>
<script>
export default {
  props:['id','name'],
  name: "UserProfile",
  //进入路由之前
  beforeRouteEnter:(to,from,next)=>{
    console.log('在进入路由前执行');
    next(vm=>{
      vm.getData();//进入路由之前执行getData()
    });
  },
  //进入路由之后
  beforeRouteLeave:(to,from,next)=>{
    console.log('在离开路由前执行');
    next();
  },
  methods:{
    getData :function (){
     this.axios({
       method:'get',
       //url:'http://localhost:8080/static/mock/data.json'
       url:'static/mock/data.json'
     }).then(function (response){
       console.log(response);
     });

    }
  }
}
</script>
<style scoped>
</style>
